import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { Route, Router, IndexRoute, browserHistory } from 'react-router';

//Actions
import * as counterAction from '../actions/counter.js';

//UI components
import App from '../pages/layout/AppLayoutView.jsx';
import Home from '../pages/home/Content.jsx';
import Counter from '../pages/counter/Content.jsx';
import Auther from '../pages/auther/Content.jsx';

//Url
import { url } from '../util/url.js';

// Map Redux state to component props
function mapStateToProps(state){
  return {
    value: state.count
  };
}

// Map Redux actions to component props
function mapDispatchToProps(dispatch) {
  return {
  	actions: bindActionCreators(counterAction, dispatch)
  };
}

// Connected Component:
var counter = connect(mapStateToProps, mapDispatchToProps)(Counter);

export default (
	<Router history={browserHistory}>
		<Route path="/" component={App}>
			<IndexRoute component={Home}/>
			<Route path={url.auther} component={Auther}/>
			<Route path={url.home} component={Home}/>
			<Route path={url.counter} component={counter}/>
		</Route>
	</Router>
);


